function gewStaticBatch()
{
  this.nodeList = [];
  this.glBuffers = {};
  this.center = new gewVec3();
}

gewStaticBatch.prototype = {
  isVFC: function()
  {
    var list = this.nodeList;
    var len = list.length;
    for (var i = 0; i < len; i++) 
    {
      if (list[i].getFlag(NODE_FRUSTUM_CULLED)) 
        return true;
    }
    return false;
  },
  addNode: function(node)
  {
    var nodeNum = this.nodeList.length;
    var nodeCenter = node.worldSphere.center;
    if (nodeNum == 0) 
    {
      this.center = nodeCenter;
      this.nodeList.push(node);
      return true;
    } 
    else 
    {
      var disVector = nodeCenter.sub(this.center);
      if (disVector.getLength() < GEW_STATIC_BATCH_RADIUS) 
      {
        var totalVec = this.center.mulScalar(nodeNum);
        this.nodeList.push(node);
        var new_center = totalVec.add(nodeCenter).divScalar(nodeNum+1);
        this.center = new_center;
        return true;
      } 
      else 
        return false;
    }
    return false;
  },
  removeNode: function(node)
  {
    var list = this.nodeList;
    var len = list.length;
    for (var i = 0; i < len; i++) 
    {
      if (list[i] == node) 
      {
        list.splice(i, 1);
        break;
      }
    }
  },
  commit:function(gl)// translate mesh vertex into world condinate and send them to glbuffer
  {
    var vbuf = [];
    var tbuf = [];
    var nbuf = [];
    var ibuf = [];
    var offset = 0;
    var ioffset = 0;
    var list = this.nodeList;
    var len = list.length;
    for (var i = 0; i < len; i++) 
    {
      var node = list[i];
      var modelMat = node.modelMat;
      var normalMat = modelMat.dup();
      normalMat.data[12] = 0;
      normalMat.data[13] = 0;
      normalMat.data[14] = 0;
      var m = node.mesh;
      var n_vbuf = m.vertices;
      var n_tbuf = m.texcoords;
      var n_nbuf = m.normals;
      var n_ibuf = m.indices[0];
      var ver_num = n_vbuf.length/3;
      for(var v=0;v<ver_num;v++)
      {  
        var offset2 = v*3;
        var t_v = modelMat.mulVec3( new gewVec3(n_vbuf[offset2],
                                                n_vbuf[offset2+1],
                                                n_vbuf[offset2+2]) );
        var t_n = normalMat.mulVec3( new gewVec3(n_nbuf[offset2],
                                                n_nbuf[offset2+1],
                                                n_nbuf[offset2+2]) );
        vbuf.push(t_v.x);
        vbuf.push(t_v.y);
        vbuf.push(t_v.z);
        
        nbuf.push(t_n.x);
        nbuf.push(t_n.y);
        nbuf.push(t_n.z);
        
        tbuf.push(n_tbuf[v*2]);
        tbuf.push(n_tbuf[v*2+1]);
      }
      var indices_len = n_ibuf.length;
      for (var ind = 0; ind < indices_len; ind++) 
      {
        ibuf.push( n_ibuf[ind]+ offset );
      }
      offset+=ver_num;
      ioffset+=indices_len;
    }
    this.vbuf = vbuf;
    this.tbuf = tbuf;
    this.nbuf = nbuf;
    this.ibuf = ibuf;
    //this.ibuf = n_ibuf;
    // create glbuf
    var ver_buff = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, ver_buff);
    gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray(vbuf), gl.STATIC_DRAW);
    //gl.bufferData(gl.ARRAY_BUFFER, n_vbuf, gl.STATIC_DRAW);
    this.glBuffers.positions = ver_buff;
    
    var tex_buff = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, tex_buff);
    gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray(tbuf), gl.STATIC_DRAW);
    //gl.bufferData(gl.ARRAY_BUFFER, n_tbuf, gl.STATIC_DRAW);
    this.glBuffers.texcoords = tex_buff;
    
    var nor_buff = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, nor_buff);
    gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray(nbuf), gl.STATIC_DRAW);
    //gl.bufferData(gl.ARRAY_BUFFER, n_nbuf, gl.STATIC_DRAW);
    this.glBuffers.normals = nor_buff;
    
    this.glBuffers.indices = [];
    //for (var i = 0; i < 1; i++) 
    {
      var ind_buff = gl.createBuffer();
      gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ind_buff);
      gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new WebGLUnsignedShortArray(ibuf), gl.STATIC_DRAW);
      //gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, n_ibuf, gl.STATIC_DRAW);
      this.glBuffers.indices[0] = ind_buff;
    }
  },
  update: function() // call each frame
  {
  },
  render: function(material)
  {
    var effect = material.effect;
    var gl = effect.gl;
    //Set up vertex att pointers
    gl.bindBuffer(gl.ARRAY_BUFFER, this.glBuffers.positions);
    gl.vertexAttribPointer(effect.inPosition, 3, gl.FLOAT, false, 0, 0);
    gl.bindBuffer(gl.ARRAY_BUFFER, this.glBuffers.texcoords);
    gl.vertexAttribPointer(effect.inTexCoord0, 2, gl.FLOAT, false, 0, 0);
    gl.bindBuffer(gl.ARRAY_BUFFER, this.glBuffers.normals);
    gl.vertexAttribPointer(effect.inNormal, 3, gl.FLOAT, false, 0, 0); 
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.glBuffers.indices[0]);
    gl.drawElements(gl.TRIANGLES,this.ibuf.length,gl.UNSIGNED_SHORT,0);
    //console.log(this.ibuf.length);
  }
}
